aux_segments = unique(aug_data.segment_id);
filter = NaN(size(aug_data,1),1);
for i=1:1:length(aux_segments)
filter(aug_data.segment_id == aux_segments(i)) = isoutlier(aug_data(aug_data.segment_id == aux_segments(i),:).speed,'quartiles');
aug_data.filter = ~logical(filter);
aux_segments = unique(osrm_data_sp.segment_id);
filter = NaN(size(osrm_data_sp,1),1);
for i=1:1:length(aux_segments)
filter(osrm_data_sp.segment_id == aux_segments(i)) = isoutlier(osrm_data_sp(osrm_data_sp.segment_id == aux_segments(i),:).speed,'quartiles');
osrm_data_sp.filter = ~logical(filter);
[a,b] = findgroups(osrm_data_sp.arac_id);
color_1 = rand(length(b),3);
scatter(ax1, osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3,osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).speed ,5,color_1(a(osrm_data_sp.dir == dir_chosen)),'filled');
scatter(ax1, aug_data(aug_data.dir == dir_chosen,:).distance_from_start * 1e-3,aug_data(aug_data.dir == dir_chosen,:).speed ,5,"red",'filled','MarkerFaceAlpha',0.3);
title(ax1,['MAT + AUG --> dir = ', num2str(dir_chosen), ' speed color: MAT(arac-id) red:AUG'])
xlabel(ax1,'st km from kızılay')
ylabel(ax1,'speed km/hr')
yLimits = get(ax1,'YLim');
line(ax1,1e-3*[markers.distance_from_start(markers.dir == dir_chosen),markers.distance_from_start(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
% text(ax1, 1e-3*markers.distance_from_start(markers.dir == dir_chosen), 0.7*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
min_x = min(osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3);
max_x = max(osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3);
xlim(ax1,[min_x , max_x]);
scatter(ax1,osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3,osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).speed ,5,color_1(a(osrm_data_sp.dir == dir_chosen)),'filled');
scatter(ax1, aug_data(aug_data.dir == dir_chosen,:).distance_from_start * 1e-3,aug_data(aug_data.dir == dir_chosen,:).speed ,5,"red",'filled','MarkerFaceAlpha',0.3);
yLimits = get(ax1,'YLim');
line(ax1,1e-3*[markers.distance_from_start(markers.dir == dir_chosen),markers.distance_from_start(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, 1e-3*markers.distance_from_start(markers.dir == dir_chosen), 0.7*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
title(ax1,'y lim [-20 400]')
xlabel(ax1,'st km from kızılay')
ylabel(ax1,'speed km/hr')
min_x = min(osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3);
max_x = max(osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3);
xlim(ax1,[min_x , max_x]);
set(h,'Units','normalized','Position',[0 0 1 0.5]);
scatter(ax1, osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3,osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).speed ,5,color_1(a(osrm_data_sp.dir == dir_chosen)),'filled');
scatter(ax1, aug_data(aug_data.dir == dir_chosen,:).distance_from_start * 1e-3,aug_data(aug_data.dir == dir_chosen,:).speed ,5,"red",'filled','MarkerFaceAlpha',0.3);
yLimits = get(ax1,'YLim');
line(ax1,1e-3*[markers.distance_from_start(markers.dir == dir_chosen),markers.distance_from_start(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
% text(ax1, 1e-3*markers.distance_from_start(markers.dir == dir_chosen), 0.7*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
title(ax1,['MAT + AUG <-- dir = ', num2str(dir_chosen), ' speed color:MAT(arac-id) red: AUG']);
xlabel(ax1,'st km from kızılay')
ylabel(ax1,'speed km/hr')
min_x = min(osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3);
max_x = max(osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3);
ax1.XTick = int64(linspace(min_x,max_x,9));
ax1.XTickLabel = num2cell(int64(linspace(min_x,max_x,9)));
xlim(ax1,[min_x , max_x]);
set(ax1, 'XTickLabel', flip(ax1.XTickLabel));
scatter(ax1,osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3,osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).speed ,5,color_1(a(osrm_data_sp.dir == dir_chosen)),'filled');
scatter(ax1, aug_data(aug_data.dir == dir_chosen,:).distance_from_start * 1e-3,aug_data(aug_data.dir == dir_chosen,:).speed ,5,"red",'filled','MarkerFaceAlpha',0.3);
yLimits = get(ax1,'YLim');
line(ax1,1e-3*[markers.distance_from_start(markers.dir == dir_chosen),markers.distance_from_start(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, 1e-3*markers.distance_from_start(markers.dir == dir_chosen), 0.7*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
set(h,'Units','normalized','Position',[0 0 1 0.5]);
title(ax1,'y lim [-20 400]')
xlabel(ax1,'st km from kızılay')
ylabel(ax1,'speed km/hr')
min_x = min(osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3);
max_x = max(osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3);
xlim(ax1,[min_x , max_x]);
ax1.XTick = int64(linspace(min_x,max_x,9));
ax1.XTickLabel = num2cell(int64(linspace(min_x,max_x,9)));
set(ax1, 'XTickLabel', flip(ax1.XTickLabel));
% set(ax1, 'XTickLabel', flip(ax1.XTickLabel));
[a,b] = findgroups(osrm_data_sp.arac_id);
color_1 = rand(length(b),3);
index = osrm_data_sp.filter & (osrm_data_sp.dir == dir_chosen);
index2 = aug_data.filter & (aug_data.dir == dir_chosen);
scatter(ax1, osrm_data_sp(index,:).distance_from_start * 1e-3,osrm_data_sp(index,:).speed ,5,color_1(a(index)),'filled');
scatter(ax1, aug_data(index2,:).distance_from_start * 1e-3,aug_data(index2,:).speed ,5,"red",'filled','MarkerFaceAlpha',0.3);
title([' MAT* + AUG* --> dir = ', num2str(dir_chosen), ' speed color:MAT(arac-id) red: AUG']);
xlabel('st km from kızılay')
yLimits = get(ax1,'YLim');
line(ax1,1e-3*[markers.distance_from_start(markers.dir == dir_chosen),markers.distance_from_start(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, 1e-3*markers.distance_from_start(markers.dir == dir_chosen), 0.7*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
min_x = min(osrm_data_sp(index,:).distance_from_start * 1e-3);
max_x = max(osrm_data_sp(index,:).distance_from_start * 1e-3);
xlim(ax1,[min_x , max_x]);
index = osrm_data_sp.filter & (osrm_data_sp.dir == dir_chosen);
index2 = aug_data.filter & (aug_data.dir == dir_chosen);
scatter(ax1, osrm_data_sp(index,:).distance_from_start * 1e-3,osrm_data_sp(index,:).speed ,10,color_1(a(index)),'filled');
scatter(ax1, aug_data(index2,:).distance_from_start * 1e-3,aug_data(index2,:).speed ,5,"red",'filled','MarkerFaceAlpha',0.3);
title([' MAT* + AUG* <-- dir = ', num2str(dir_chosen), ' speed color:MAT(arac-id) red: AUG']);
xlabel(ax1, 'st km from kızılay')
ylabel(ax1,'speed km/hr')
min_x = min(osrm_data_sp(index,:).distance_from_start * 1e-3);
max_x = max(osrm_data_sp(index,:).distance_from_start * 1e-3);
xlim(ax1,[min_x , max_x]);
yLimits = get(ax1,'YLim');
line(ax1,1e-3*[markers.distance_from_start(markers.dir == dir_chosen),markers.distance_from_start(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, 1e-3*markers.distance_from_start(markers.dir == dir_chosen), 0.7*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
xlim(ax1,[min_x , max_x]);
ax1.XTick = int64(linspace(min_x,max_x,9));
ax1.XTickLabel = num2cell(int64(linspace(min_x,max_x,9)));
set(ax1, 'XTickLabel', flip(ax1.XTickLabel));
set(h,'Units','normalized','Position',[0 0 1 0.5]);
scatter(osrm_data_sp.space_distance,osrm_data_sp.speed,10,'filled')
xlabel('space difference b/w points (meter)')
ylabel('corresponding speed km/hr')
title(' MAT delta-x vs speed for both dir-s')
scatter(osrm_data_sp.time_distance * 60 * 60,osrm_data_sp.speed,10,'filled')
xlabel('time difference b/w points - seconds-')
ylabel('corresponding speed km/hr')
title(' MAT delta-x vs speed for both dir-s')
scatter(osrm_data_sp(osrm_data_sp.filter,:).space_distance,osrm_data_sp(osrm_data_sp.filter,:).speed,10,'filled')
xlabel('space difference b/w points (meter)')
ylabel('corresponding speed km/hr')
title(' MAT* delta-x vs speed for both dir-s')
scatter(osrm_data_sp(osrm_data_sp.filter,:).time_distance * 60 * 60,osrm_data_sp(osrm_data_sp.filter,:).speed,10,'filled')
xlabel(' time difference b/w points - seconds-')
ylabel('corresponding speed km/hr')
title(' MAT* delta-x vs speed for both dir-s')
scatter3(osrm_data_sp(osrm_data_sp.filter,:).time_distance * 60 * 60,osrm_data_sp(osrm_data_sp.filter,:).space_distance,osrm_data_sp(osrm_data_sp.filter,:).speed,10,'filled')
index = (osrm_data_sp.dir == dir_chosen) & osrm_data_sp.filter;
index2 = (aug_data.dir == dir_chosen) & aug_data.filter;
boxchart(ax1,double(osrm_data_sp.segment_id(index)) ,osrm_data_sp.speed(index),"MarkerStyle",'.',"WhiskerLineColor","blue",'LineWidth',1.5);
boxchart(ax1,double(aug_data.segment_id(index2)) ,aug_data.speed(index2),"MarkerStyle",'.',"WhiskerLineColor","red",'LineWidth',0.5);
legend(ax1,'AutoUpdate','off')
legend(ax1,'MAT*',"AUG*")
title(ax1,'MAT* + AUG* --> direction = 1 8:00-10:00 segment id vs speed boxplot')
xlabel(ax1,'segment id (kızılay - > polatlı)')
xlim(ax1,[min(double(osrm_data_sp.segment_id(index))) - 1, max(double(osrm_data_sp.segment_id(index))) + 1])
% set(ax1,'YLim',[0 200])
yLimits = get(ax1,'YLim');
line(ax1,[markers.segment_id(markers.dir == dir_chosen),markers.segment_id(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, double(markers.segment_id(markers.dir == dir_chosen)), 0.8*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
index = osrm_data_sp.dir == dir_chosen & osrm_data_sp.filter;
index2 = (aug_data.dir == dir_chosen) & aug_data.filter;
boxchart(ax2,double(osrm_data_sp.segment_id(index)) ,osrm_data_sp.speed(index),"MarkerStyle",'.',"WhiskerLineColor","blue",'LineWidth',1.5);
boxchart(ax2,double(aug_data.segment_id(index2)) ,aug_data.speed(index2),"MarkerStyle",'.',"WhiskerLineColor","red",'LineWidth',0.5);
legend(ax1,'AutoUpdate','off')
legend(ax1,'MAT*',"AUG*")
min_x = min(double(osrm_data_sp.segment_id(index)));
max_x = max(double(osrm_data_sp.segment_id(index)));
ax2.XLim = [ min_x - 1 , max_x + 1];
% ax2.XTick = int64(linspace(min_x,max_x,10));
set(h,'Units','normalized','Position',[0 0 1 0.5]);
title(ax2,'MAT* +AUG* <-- direction = 2 8:00-10:00 segment id vs speed boxplot')
xlabel(ax2,'segment id (kızılay -> polatlı)')
yLimits = get(ax2,'YLim');
line(ax2,[markers.segment_id(markers.dir == dir_chosen),markers.segment_id(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax2, double(markers.segment_id(markers.dir == dir_chosen)), 0.7*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
index = aug_data.dir == dir_chosen;
index2 = osrm_data_sp.dir == dir_chosen;
[GC,GR] = groupcounts(aug_data.segment_id(index));
[GC2,GR2] = groupcounts(osrm_data_sp.segment_id(index2));
bar(ax1,GR2,GC2,'FaceAlpha',0.3,'EdgeAlpha',0.7);
bar(ax1,GR,GC,'FaceAlpha',0.3,'EdgeAlpha',0.7);
title(ax1,'AUG +MAT --> dir = 1 speed data count vs segment id')
yLimits = get(ax1,'YLim');
line(ax1,[markers.segment_id(markers.dir == dir_chosen),markers.segment_id(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, double(markers.segment_id(markers.dir == dir_chosen)), 0.7*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
% [~,b2]=ismember(segments.segment_id,GR2);
% % segments.segment_id(nonzeros(b2));
% % segments.calc_length(nonzeros(b2));
% A = [GC2 , segments.calc_length(nonzeros(b2)) * 1e-3];
% A1L = [0; cumsum(A(:,2))];
% patch(ax1,[0 1 1 0]*A(k1,2)+A1L(k1),[0 0 1 1]*A(k1,1), "blue", 'LineWidth',0.01,'FaceAlpha',0.3,'EdgeAlpha',0.7);
[a,~]=ismember(segments.segment_id,GR);
A = [GC , segments.calc_length(a) * 1e-3];
% A1L = [0; cumsum(A(:,2))];
A1L = segments.distance_from_start(a) * 1e-3;
patch(ax1,[0 1 1 0]*A(k1,2)+A1L(k1),[0 0 1 1]*A(k1,1), "red", 'LineWidth',0.01,'FaceAlpha',0.3,'EdgeAlpha',0.3);
[a2,~]=ismember(segments.segment_id,GR2);
A2 = [GC2 , segments.calc_length(a2) * 1e-3];
A1L2 = segments.distance_from_start(a2) * 1e-3;
patch(ax1,[0 1 1 0]*A2(k1,2)+A1L2(k1),[0 0 1 1]*A2(k1,1), "blue", 'LineWidth',0.01,'FaceAlpha',0.3,'EdgeAlpha',0.3);
axis(ax1,[min(A1L) max(A1L) 0 max(ylim)])
yLimits = get(ax1,'YLim');
line(ax1,1e-3 * [markers.distance_from_start(markers.dir == dir_chosen),markers.distance_from_start(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, 1e-3 * double(markers.distance_from_start(markers.dir == dir_chosen)), 0.75*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
set(h,'Units','normalized','Position',[0 0 1 0.5]);
title(ax1,'AUG --> dir = 1 speed data counts vs segments - bar width = segment length(km)')
xlabel(ax1,'km from kızılay')
ylabel(ax1,'aug data count')
index = aug_data.dir == dir_chosen;
index2 = osrm_data_sp.dir == dir_chosen;
[GC,GR] = groupcounts(aug_data.segment_id(index));
[GC2,GR2] = groupcounts(osrm_data_sp.segment_id(index2));
bar(ax1,GR2,GC2,'FaceAlpha',0.3,'EdgeAlpha',0.7);
bar(ax1,GR,GC,'FaceAlpha',0.3,'EdgeAlpha',0.7);
title(ax1,'AUG +MAT --> dir = 2 speed data count vs segment id')
yLimits = get(ax1,'YLim');
line(ax1,[markers.segment_id(markers.dir == dir_chosen),markers.segment_id(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, double(markers.segment_id(markers.dir == dir_chosen)), 0.7*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
[a,~]=ismember(segments.segment_id,GR);
A = [GC , segments.calc_length(a) * 1e-3];
% A1L = [0; cumsum(A(:,2))];
A1L = segments.distance_from_start(a) * 1e-3;
patch(ax1,[0 1 1 0]*A(k1,2)+A1L(k1),[0 0 1 1]*A(k1,1), "red", 'LineWidth',0.01,'FaceAlpha',0.3,'EdgeAlpha',0.3);
[a2,~]=ismember(segments.segment_id,GR2);
A2 = [GC2 , segments.calc_length(a2) * 1e-3];
A1L2 = segments.distance_from_start(a2) * 1e-3;
patch(ax1,[0 1 1 0]*A2(k1,2)+A1L2(k1),[0 0 1 1]*A2(k1,1), "blue", 'LineWidth',0.01,'FaceAlpha',0.3,'EdgeAlpha',0.3);
axis([min_x max_x 0 max(ylim)])
set(h,'Units','normalized','Position',[0 0 1 0.5]);
yLimits = get(ax1,'YLim');
line(ax1,1e-3 * [markers.distance_from_start(markers.dir == dir_chosen),markers.distance_from_start(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, 1e-3 * double(markers.distance_from_start(markers.dir == dir_chosen)), 0.75*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
xlim(ax1,[min_x , max_x]);
ax1.XTick = int64(linspace(min_x,max_x,9));
ax1.XTickLabel = num2cell(int64(linspace(min_x,max_x,9)));
set(ax1, 'XTickLabel', flip(ax1.XTickLabel));
title('AUG <-- dir = 2 speed data counts vs segments - bar width = segment length(km)')
xlabel('st km from kızılay')
index = (aug_data.dir == dir_chosen) & (~isnan(aug_data.speed)) & aug_data.filter;
[G,b] = findgroups(aug_data.segment_id(index));
plot(ax1, b, splitapply(@mean,aug_data.speed(index),G),'-+')
get_ave = @(x) hours(sum(x)) / length(x);
[~,y] = ismember(b,segments.segment_id);
plot(ax1, b, 1e-3 * segments.calc_length(y) ./ splitapply(get_ave, aug_data.time_diff(index),G),'-*')
set(h,'Units','normalized','Position',[0 0 1 0.5]);
title({'AUG* direction = 1 8:00-10:00 segment id vs AVERAGE speed',...
yLimits = get(ax1,'YLim');
line(ax1,[markers.segment_id(markers.dir == dir_chosen),markers.segment_id(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, double(markers.segment_id(markers.dir == dir_chosen)), 0*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
ax1.XLim = [ min(b) - 1 , max(b) + 1];
legend('mean v over segment','v from travel time mean')
index = (aug_data.dir == dir_chosen) & (~isnan(aug_data.speed)) & aug_data.filter;
[G,b] = findgroups(aug_data.segment_id(index));
plot(ax1, b, splitapply(@mean,aug_data.speed(index),G),'-+')
get_ave = @(x) hours(sum(x)) / length(x);
[~,y] = ismember(b,segments.segment_id);
plot(ax1, b, 1e-3 * segments.calc_length(y) ./ splitapply(get_ave, aug_data.time_diff(index),G),'-*')
set(h,'Units','normalized','Position',[0 0 1 0.5]);
title(ax1,' AUG* <-- direction = 2 8:00-10:00 segment id vs AVERAGE speed')
yLimits = get(ax1,'YLim');
line(ax1,[markers.segment_id(markers.dir == dir_chosen),markers.segment_id(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, double(markers.segment_id(markers.dir == dir_chosen)), 0*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
ax1.XLim = [ min(b) - 1 , max(b) + 1];
legend('mean v over segment','v from travel time mean')
index = (aug_data.dir == dir_chosen) & (~isnan(aug_data.speed)) & aug_data.filter;
[G,b] = findgroups(aug_data.segment_id(index));
b2 = ismember(segments.segment_id,b);
plot(ax1, 1e-3*segments.distance_from_start(b2), splitapply(@mean,aug_data.speed(index),G),'-+')
get_ave = @(x) hours(sum(x)) / length(x);
[~,y] = ismember(b,segments.segment_id);
plot(ax1, 1e-3*segments.distance_from_start(b2), 1e-3 * segments.calc_length(y) ./ splitapply(get_ave, aug_data.time_diff(index),G),'-*')
title({'AUG* direction = 1 8:00-10:00 AVERAGE speed vs st km',...
yLimits = get(ax1,'YLim');
line(ax1,[1e-3*markers.distance_from_start(markers.dir == dir_chosen),1e-3*markers.distance_from_start(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, 1e-3*double(markers.distance_from_start(markers.dir == dir_chosen)), 0*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
min_x = min(1e-3*segments.distance_from_start(b2));
max_x = max(1e-3*segments.distance_from_start(b2));
xlim(ax1,[min_x , max_x]);
xlabel('st km from kızılay')
legend('mean v over segment','v from travel time mean')
index = (aug_data.dir == dir_chosen) & (~isnan(aug_data.speed)) & aug_data.filter;
[G,b] = findgroups(aug_data.segment_id(index));
b2 = ismember(segments.segment_id,b);
plot(ax1, 1e-3*segments.distance_from_start(b2), splitapply(@mean,aug_data.speed(index),G),'-+')
get_ave = @(x) hours(sum(x)) / length(x);
[~,y] = ismember(b,segments.segment_id);
plot(ax1, 1e-3*segments.distance_from_start(b2), 1e-3 * segments.calc_length(y) ./ splitapply(get_ave, aug_data.time_diff(index),G),'-*')
set(h,'Units','normalized','Position',[0 0 1 0.5]);
title({'AUG* direction = 2 8:00-10:00 AVERAGE speed vs st km'})
yLimits = get(ax1,'YLim');
line(ax1,[1e-3*markers.distance_from_start(markers.dir == dir_chosen),1e-3*markers.distance_from_start(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, 1e-3*double(markers.distance_from_start(markers.dir == dir_chosen)), 0*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
% ax1.XLim = [ 1e-3*min(segments.distance_from_start(b2)) - 1 , 1e-3*max(segments.distance_from_start(b2)) + 1];
min_x = min(1e-3*segments.distance_from_start(b2));
max_x = max(1e-3*segments.distance_from_start(b2));
xlim(ax1,[min_x , max_x]);
% ax1.XTick = int64(linspace(min_x,max_x,10));
% ax1.XTickLabel = num2cell(ax1.XTick);
set(ax1, 'XTickLabel', "");
xlabel('st km from kızılay')
legend('mean v over segment','v from travel time mean')
index = aug_data.dir == dir_chosen;
boxchart(ax1, double(aug_data.segment_id(index)) ,aug_data.speed(index),"MarkerStyle",'.','MarkerColor','red')
set(h,'Units','normalized','Position',[0 0 1 0.5]);
title('AUG --> direction = 1 8:00-8:30 segment id vs speed boxplot')
xlabel('segment id kızılay -> polatlı')
yLimits = get(ax1,'YLim');
line(ax1,[markers.segment_id(markers.dir == dir_chosen),markers.segment_id(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, double(markers.segment_id(markers.dir == dir_chosen)), 0.7*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
ax1.XLim = [min(double(aug_data.segment_id(index))) , max(double(aug_data.segment_id(index)))];
index = aug_data.dir == dir_chosen;
boxchart(ax1,double(aug_data.segment_id(index)) ,aug_data.speed(index),"MarkerStyle",'.','MarkerColor','red')
min_x = min(double(aug_data.segment_id(index)));
max_x = max(double(aug_data.segment_id(index)));
ax1.XLim = [ min_x - 1 , max_x + 1];
ax1.XTick = int64(linspace(min_x,max_x,10));
yLimits = get(ax1,'YLim');
line(ax1,[markers.segment_id(markers.dir == dir_chosen),markers.segment_id(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, double(markers.segment_id(markers.dir == dir_chosen)), 0.7*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
ax1.XLim = [min(double(aug_data.segment_id(index))) , max(double(aug_data.segment_id(index)))];
xlabel('segment id kızılay -> polatlı')
set(h,'Units','normalized','Position',[0 0 1 0.5]);
title(' AUG <-- direction = 2 8:00-8:30 segment id vs speed boxplot')
time_1 = datetime({'2019-11-18 08:00:00'});
time_2 = datetime({'2019-11-18 10:00:00'});
aux_time = time_1:minutes(30):time_2;
for i=1:1:length(aux_time)-1
ax1 = subplot(length(aux_time)-1,1,i);
index = aug_data.dir == dir_chosen & aug_data.time >= aux_time(i) & aug_data.time < aux_time(i+1);
boxchart(ax1,double(aug_data.segment_id(index)) ,aug_data.speed(index),"MarkerStyle",'.','MarkerColor','red')
title(ax1,['AUG ', datestr(aux_time(i)), '---', datestr(aux_time(i+1)),' ','direction = ', num2str(dir_chosen), 'segment id vs speed boxplot ndata = ',num2str(sum(index))])
yLimits = get(ax1,'YLim');
line(ax1,[markers.segment_id(markers.dir == dir_chosen),markers.segment_id(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
ax1.XLim = [min(double(aug_data.segment_id(index))) , max(double(aug_data.segment_id(index)))];
text(ax1, double(markers.segment_id(markers.dir == dir_chosen)), -0.1*repmat(yLimits(1),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
ax1.XLim = [min(double(aug_data.segment_id(index))) , max(double(aug_data.segment_id(index)))];
set(h,'Units','normalized','Position',[0 0 1 1]);
time_1 = datetime({'2019-11-18 08:00:00'});
time_2 = datetime({'2019-11-18 10:00:00'});
aux_time = time_1:minutes(30):time_2;
for i=1:1:length(aux_time)-1
ax1 = subplot(length(aux_time)-1,1,i);
index = aug_data.dir == dir_chosen & aug_data.time >= aux_time(i) & aug_data.time < aux_time(i+1);
boxchart(ax1, double(aug_data.segment_id(index)) ,aug_data.speed(index),"MarkerStyle",'.','MarkerColor','red')
ax1.XLim = [ min_x - 1 , max_x + 1];
ax1.XTick = int64(linspace(min_x,max_x,10));
title('AUG ', [datestr(aux_time(i)), '---', datestr(aux_time(i+1)),' ','direction = ', num2str(dir_chosen), 'segment id vs speed boxplot ndata = ',num2str(sum(index))])
yLimits = get(ax1,'YLim');
line(ax1,[markers.segment_id(markers.dir == dir_chosen),markers.segment_id(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
ax1.XLim = [min(double(aug_data.segment_id(index))) , max(double(aug_data.segment_id(index)))];
text(ax1, double(markers.segment_id(markers.dir == dir_chosen)), -0.1*repmat(yLimits(1),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
ax1.XLim = [min(double(aug_data.segment_id(index))) , max(double(aug_data.segment_id(index)))];
set(h,'Units','normalized','Position',[0 0 1 1]);
xlabel(' segment id kızılay -> polatlı')
scatter(aug_data.space_diff,aug_data.speed,10,'filled')
xlabel('space difference b/w points (meter)')
ylabel('corresponding speed km/hr')
title(' AUG delta-x vs speed for both dir-s')
scatter(hours(aug_data.time_diff) * 60 * 60,aug_data.speed,10,'filled')
xlabel('time difference b/w points - seconds-')
ylabel('corresponding speed km/hr')
title(' AUG delta-x vs speed for both dir-s')
scatter(aug_data(aug_data.filter,:).space_diff,aug_data(aug_data.filter,:).speed,10,'filled')
xlabel('space difference b/w points (meter)')
ylabel('corresponding speed km/hr')
title({'AUG* delta-x vs speed for both dir-s', ...
' not: uzun yolda segment lengthler uniform gidiyor sanırım', ...
'segment length kısa -> şehiriçi -> hız düşük'})
scatter(hours(aug_data(aug_data.filter,:).time_diff) * 60 * 60,aug_data(aug_data.filter,:).speed,10,'filled')
xlabel(' time difference b/w points - seconds-')
ylabel('corresponding speed km/hr')
title({'AUG* delta-x vs speed for both dir-s', ...
'not: 1/n fonksiyonu v = dx/dt yine de biraz mantıksız? dx sabit mi'})
scatter(hours(aug_data(aug_data.filter,:).time_diff) * 60 * 60,aug_data(aug_data.filter,:).space_diff,10,'filled')
xlabel(' time difference b/w points - seconds-')
title({'AUG* delta-x vs delta-t'})
index = (aug_data.dir == dir_chosen) & aug_data.filter;
boxchart(ax1, double(aug_data.segment_id(index)) ,aug_data.speed(index),"MarkerStyle",'.','MarkerColor','red')
title(ax1,'AUG* --> direction = 1 8:00-10:00 segment id vs speed boxplot after outlier')
yLimits = get(ax1,'YLim');
line(ax1,[markers.segment_id(markers.dir == dir_chosen),markers.segment_id(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, double(markers.segment_id(markers.dir == dir_chosen)), 0.7*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
ax1.XLim = [min(double(aug_data.segment_id(index))) , max(double(aug_data.segment_id(index)))];
index = (aug_data.dir == dir_chosen) & aug_data.filter;
boxchart(ax1, double(aug_data.segment_id(index)) ,aug_data.speed(index),"MarkerStyle",'.','MarkerColor','red')
min_x = min(double(aug_data.segment_id(index)));
max_x = max(double(aug_data.segment_id(index)));
ax1.XLim = [ min_x - 1 , max_x + 1];
ax1.XTick = int64(linspace(min_x,max_x,10));
set(h,'Units','normalized','Position',[0 0 1 0.5]);
title(ax1,'AUG* <-- direction = 2 8:00-10:00 segment id vs speed boxplot after outlier');
xlabel(ax1,'segment id kızılay ->polatlı');
ylabel(ax1,'speed km/h');
yLimits = get(ax1,'YLim');
line(ax1,[markers.segment_id(markers.dir == dir_chosen),markers.segment_id(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, double(markers.segment_id(markers.dir == dir_chosen)), 0.7*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
ax1.XLim = [min(double(aug_data.segment_id(index))) , max(double(aug_data.segment_id(index)))];
time_1 = datetime({'2019-11-18 08:00:00'});
time_2 = datetime({'2019-11-18 10:00:00'});
aux_time = time_1:minutes(30):time_2;
for i=1:1:length(aux_time)-1
ax1 = subplot(length(aux_time)-1,1,i);
index = aug_data.dir == dir_chosen & aug_data.time >= aux_time(i) & aug_data.time < aux_time(i+1) & aug_data.filter;
boxchart(ax1, double(aug_data.segment_id(index)) ,aug_data.speed(index),"MarkerStyle",'.','MarkerColor','red')
min_x = min(double(aug_data.segment_id(index)));
max_x = max(double(aug_data.segment_id(index)));
ax1.XLim = [ min_x - 1 , max_x + 1];
% ax1.XTick = int64(linspace(min_x,max_x,10));
title(['AUG* ',datestr(aux_time(i)), '---', datestr(aux_time(i+1)),' ','direction = ', num2str(dir_chosen), 'segment id vs speed boxplot ndata = ',num2str(sum(index))]);
yLimits = get(ax1,'YLim');
line(ax1,[markers.segment_id(markers.dir == dir_chosen),markers.segment_id(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, double(markers.segment_id(markers.dir == dir_chosen)), -0.6*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
set(h,'Units','normalized','Position',[0 0 1 1]);
xlabel('segment id kızılay ->polatlı')
time_1 = datetime({'2019-11-18 08:00:00'});
time_2 = datetime({'2019-11-18 10:00:00'});
aux_time = time_1:minutes(30):time_2;
for i=1:1:length(aux_time)-1
ax1 = subplot(length(aux_time)-1,1,i);
index = aug_data.dir == dir_chosen & aug_data.time >= aux_time(i) & aug_data.time < aux_time(i+1) & aug_data.filter;
boxchart(ax1, double(aug_data.segment_id(index)) ,aug_data.speed(index),"MarkerStyle",'.','MarkerColor','red')
min_x = min(double(aug_data.segment_id(index)));
max_x = max(double(aug_data.segment_id(index)));
ax1.XLim = [ min_x - 1 , max_x + 1];
ax1.XTick = int64(linspace(min_x,max_x,10));
title(['AUG* ',datestr(aux_time(i)), '---', datestr(aux_time(i+1)),' ','direction = ', num2str(dir_chosen), 'segment id vs speed boxplot ndata = ',num2str(sum(index))]);
yLimits = get(ax1,'YLim');
line(ax1,[markers.segment_id(markers.dir == dir_chosen),markers.segment_id(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
text(ax1, double(markers.segment_id(markers.dir == dir_chosen)), -0.6*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
set(h,'Units','normalized','Position',[0 0 1 1]);
xlabel('segment id kızılay ->polatlı')
index = aug_data.filter & aug_data.dir == dir_chosen & ~isnan(aug_data.speed);
color_1 = zeros(sum(index),1);
a = findgroups(aug_data(index,{'arac_id','route_id'}));
[mat,color_1(aux_index),limits] = get_speed_color(aug_data(index,:).speed(aux_index));
scatter(ax1,aug_data.time(index), aug_data.distance_from_start(index),10,mat(color_1,:),'filled');
ylabel(ax1,'distance from start point POLATLI (m)');
caxis(ax1,[0,limits(1)+15]);
c.Ticks = linspace(0,limits(1)+15,size(limits,2)+2);
title(ax1,'AUG* dir = 1')
xLimits = get(ax1,'XLim');
line(ax1,[xLimits(1),xLimits(2)],[markers.distance_from_start(markers.dir == dir_chosen),markers.distance_from_start(markers.dir == dir_chosen)] ,'LineStyle','--','LineWidth',0.1,'Color','magenta');
text(ax1, repmat(xLimits(1)- minutes(7),sum((markers.dir == dir_chosen)),1), double(markers.distance_from_start(markers.dir == dir_chosen)),(markers.names(markers.dir == dir_chosen)),'HorizontalAlignment', 'right');
index = osrm_data_sp.filter & osrm_data_sp.dir == dir_chosen & ~isnan(osrm_data_sp.speed);
color_1 = zeros(sum(index),1);
a = findgroups(osrm_data_sp(index,{'arac_id','route_id'}));
[mat,color_1(aux_index),limits] = get_speed_color(osrm_data_sp(index,:).speed(aux_index));
scatter(ax1,osrm_data_sp.time(index), osrm_data_sp.distance_from_start(index),10,mat(color_1,:),'filled');
ylabel(ax1,'distance from start point POLATLI (m)');
caxis(ax1,[0,limits(1)+15]);
c.Ticks = linspace(0,limits(1)+15,size(limits,2)+2);
title(ax1,'MAT* dir = 1')
xLimits = get(ax1,'XLim');
line(ax1,[xLimits(1),xLimits(2)],[markers.distance_from_start(markers.dir == dir_chosen),markers.distance_from_start(markers.dir == dir_chosen)] ,'LineStyle','--','LineWidth',0.1,'Color','magenta');
text(ax1, repmat(xLimits(1)- minutes(7),sum((markers.dir == dir_chosen)),1), double(markers.distance_from_start(markers.dir == dir_chosen)),(markers.names(markers.dir == dir_chosen)),'HorizontalAlignment', 'right');
set(h,'Units','normalized','Position',[0 0 1 0.5]);
index = aug_data.filter & aug_data.dir == dir_chosen & ~isnan(aug_data.speed);
color_1 = zeros(sum(index),1);
a = findgroups(aug_data(index,{'arac_id','route_id'}));
[mat,color_1(aux_index),limits] = get_speed_color(aug_data(index,:).speed(aux_index));
scatter(ax1,aug_data.time(index), aug_data.distance_from_start(index),10,mat(color_1,:),'filled');
ylabel(ax1,'distance from start point POLATLI (m)');
caxis(ax1,[0,limits(1)+15]);
c.Ticks = linspace(0,limits(1)+15,size(limits,2)+2);
title(ax1,'AUG* dir = 2')
xLimits = get(ax1,'XLim');
line(ax1,[xLimits(1),xLimits(2)],[markers.distance_from_start(markers.dir == dir_chosen),markers.distance_from_start(markers.dir == dir_chosen)] ,'LineStyle','--','LineWidth',0.1,'Color','magenta');
text(ax1, repmat(xLimits(1)- minutes(7),sum((markers.dir == dir_chosen)),1), double(markers.distance_from_start(markers.dir == dir_chosen)),(markers.names(markers.dir == dir_chosen)),'HorizontalAlignment', 'right');
index = osrm_data_sp.filter & osrm_data_sp.dir == dir_chosen & ~isnan(osrm_data_sp.speed);
color_1 = zeros(sum(index),1);
a = findgroups(osrm_data_sp(index,{'arac_id','route_id'}));
[mat,color_1(aux_index),limits] = get_speed_color(osrm_data_sp(index,:).speed(aux_index));
scatter(ax1,osrm_data_sp.time(index), osrm_data_sp.distance_from_start(index),10,mat(color_1,:),'filled');
ylabel(ax1,'distance from start point POLATLI (m)');
caxis(ax1,[0,limits(1)+15]);
c.Ticks = linspace(0,limits(1)+15,size(limits,2)+2);
title(ax1,'MAT* dir = 2')
xLimits = get(ax1,'XLim');
line(ax1,[xLimits(1),xLimits(2)],[markers.distance_from_start(markers.dir == dir_chosen),markers.distance_from_start(markers.dir == dir_chosen)] ,'LineStyle','--','LineWidth',0.1,'Color','magenta');
text(ax1, repmat(xLimits(1)- minutes(7),sum((markers.dir == dir_chosen)),1), double(markers.distance_from_start(markers.dir == dir_chosen)),(markers.names(markers.dir == dir_chosen)),'HorizontalAlignment', 'right');
set(h,'Units','normalized','Position',[0 0 1 0.5]);
time_1 = datetime({'2019-11-18 08:00:00'});
time_2 = datetime({'2019-11-18 10:00:00'});
aux_time = time_1:minutes(15):time_2;
selected_segment_id = 43;
aux_data = aug_data(aug_data.filter & aug_data.segment_id == selected_segment_id,:);
aux_data_2 = osrm_data_sp(osrm_data_sp.filter & osrm_data_sp.segment_id == selected_segment_id,:);
min_x = min([aux_data.speed;aux_data_2.speed]);
max_x = max([aux_data.speed;aux_data_2.speed]);
for i=1:1:length(aux_time)-1
ax1 = subplot(2,length(aux_time)-1,i);
index = aux_data.time >= aux_time(i) & aux_data.time < aux_time(i+1);
histogram(ax1, aux_data.speed(index),20)
xlim(ax1,[min_x - 5 , max_x + 5])
title(ax1,{datestr(aux_time(i)), ...
datestr(aux_time(i+1)),'AUG*',[ 'segment - id = ',num2str(selected_segment_id)]});
ax2 = subplot(2,length(aux_time)-1,length(aux_time)-1+i);
index = aux_data_2.time >= aux_time(i) & aux_data_2.time < aux_time(i+1);
histogram(ax2, aux_data_2.speed(index),20)
xlim(ax2,[min_x - 5 , max_x + 5])
set(h,'Units','normalized','Position',[0 0 1 0.5]);
selected_segment_id = 40;
ax1 = subplot(1,fig_num,i+1);
histogram(ax1, aug_data(aug_data.filter & aug_data.segment_id == selected_segment_id+i,:).speed,20,'FaceAlpha',0.3,'EdgeAlpha',0.7)
histogram(ax1, osrm_data_sp(osrm_data_sp.filter & osrm_data_sp.segment_id == selected_segment_id+i,:).speed,20,'FaceAlpha',0.3,'EdgeAlpha',0.7)
% min_x = min(double(aux_data.segment_id(index)));
% max_x = max(double(aux_data.segment_id(index)));
% ax1.XLim = [ min_x - 1 , max_x + 1];
% ax1.XTick = int64(linspace(min_x,max_x,10));
% title([datestr(aux_time(i)), '---', datestr(aux_time(i+1)),' ','direction = ', num2str(aux_dir), 'segment id vs speed boxplot ndata = ',num2str(sum(index))]);
title(['segment -id= ', num2str(selected_segment_id+i),' for all time'])
set(h,'Units','normalized','Position',[0 0 1 0.5]);
gross_data = [aug_data(:,{'segment_id','time','arac_id','dir','speed','route_id','distance_from_start','filter'}) ; osrm_data_sp(:,{'segment_id','time','arac_id','dir','speed','route_id','distance_from_start','filter'})];
[GC,GR] = findgroups(gross_data.segment_id);
b = ismember(segments.segment_id,GR);
segments.q1 = NaN(size(segments.segment_id,1),1);
segments.q2 = NaN(size(segments.segment_id,1),1);
segments.q3 = NaN(size(segments.segment_id,1),1);
segments.q3(b) = splitapply(@(x) quantile(x,0.75),gross_data.speed,GC);
segments.q2(b) = splitapply(@(x) quantile(x,0.5),gross_data.speed,GC);
segments.q1(b) = splitapply(@(x) quantile(x,0.25),gross_data.speed,GC);
% scatter(ax1, segments.distance_from_start(index) , q3(index),5,"red",'filled');
% scatter(ax1, segments.distance_from_start(index) , q2(index),5,"blue",'filled');
% scatter(ax1, segments.distance_from_start(index) , q1(index),5,"magenta",'filled');
% scatter(ax1, aug_data(aug_data.dir == dir_chosen,:).distance_from_start * 1e-3,aug_data(aug_data.dir == dir_chosen,:).speed ,5,"red",'filled','MarkerFaceAlpha',0.3);
% title(ax1,['MAT + AUG --> dir = ', num2str(dir_chosen), ' speed color: MAT(arac-id) red:AUG'])
% xlabel(ax1,'st km from kızılay')
% ylabel(ax1,'speed km/hr')
% yLimits = get(ax1,'YLim');
% line(ax1,1e-3*[markers.distance_from_start(markers.dir == dir_chosen),markers.distance_from_start(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
% % text(ax1, 1e-3*markers.distance_from_start(markers.dir == dir_chosen), 0.7*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
% min_x = min(osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3);
% max_x = max(osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3);
% xlim(ax1,[min_x , max_x]);
% scatter(ax1,osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3,osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).speed ,5,color_1(a(osrm_data_sp.dir == dir_chosen)),'filled');
% scatter(ax1, aug_data(aug_data.dir == dir_chosen,:).distance_from_start * 1e-3,aug_data(aug_data.dir == dir_chosen,:).speed ,5,"red",'filled','MarkerFaceAlpha',0.3);
% yLimits = get(ax1,'YLim');
% line(ax1,1e-3*[markers.distance_from_start(markers.dir == dir_chosen),markers.distance_from_start(markers.dir == dir_chosen)] , yLimits,'LineStyle','--','LineWidth',0.1);
% text(ax1, 1e-3*markers.distance_from_start(markers.dir == dir_chosen), 0.7*repmat(yLimits(2),sum((markers.dir == dir_chosen)),1),(markers.names(markers.dir == dir_chosen)),'Rotation',90);
% title(ax1,'y lim [-20 400]')
% xlabel(ax1,'st km from kızılay')
% ylabel(ax1,'speed km/hr')
% min_x = min(osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3);
% max_x = max(osrm_data_sp(osrm_data_sp.dir == dir_chosen,:).distance_from_start * 1e-3);
% xlim(ax1,[min_x , max_x]);
% set(h,'Units','normalized','Position',[0 0 1 0.5]);
function [mat,out_labels,limits] = get_speed_color(input)
mat = [0.4706, 0.0039, 0.0039;
limits=[90,75,60,45,30,15];
out_labels = zeros(size(input,1),1);
out_labels(input >= limits(1)) = 7;
out_labels(input >= limits(2) & input < limits(1)) = 6;
out_labels(input >= limits(3) & input < limits(2)) = 5;
out_labels(input >= limits(4) & input < limits(3)) = 4;
out_labels(input >= limits(5) & input < limits(4)) = 3;
out_labels(input >= limits(6) & input < limits(5)) = 2;
out_labels(input < limits(6)) = 1;